package com.klxedu.ms.gateway.security.entrypoint;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;

import com.klxedu.ms.gateway.AuthServerConstants;
/**
 * 
 * Title: CaptchaEntryPoint<br>
 * Description: 验证码错误提示<br>
 * Copyright @ 2011~2018 Goldgov .All rights reserved.<br>
 * 
 * @author GuoR
 * @createDate 2018年7月16日
 */
public class CaptchaEntryPoint implements AuthenticationEntryPoint{
	private static final Log logger = LogFactory.getLog(CaptchaEntryPoint.class);

	@Override
	public void commence(HttpServletRequest request, HttpServletResponse response,
			AuthenticationException authException) throws IOException, ServletException {
		if (logger.isDebugEnabled()) {
			logger.debug("Pre-authenticated entry point called. Captcha faile");
		}
		response.sendError(AuthServerConstants.SC_CAPTCHA_FAIL, authException.getMessage());
	}
}
